package com.zky.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description ES配置
 * @Author 张开源
 * @Date 2022/10/16 0:40
 * @Version 1.0
 **/
@Configuration
public class ElasticSearchConfig {

    public static final RequestOptions COMMOM_OPTIONS;

    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
        COMMOM_OPTIONS = builder.build();
    }

    @Bean
    public RestHighLevelClient restHighClient() {
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("47.96.156.194", 9200, "http"))
        );
        return client;
    }
}
